package com.topnav.mc.admin.entity.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 联网设备类别
 * @Author: kenny
 * @Date: 2023/11/7 15:47
 */
public enum DeviceType {
    CAMERA_4G(1,"4G执法仪"),
    CAMERA_5G(2,"5G执法仪"),
    SAFETY_HELMET(3,"安全帽"),
    IPC(4,"IPC"),
    CAMERA_BALL(5,"布控球"),
    OTHER(6,"其它类型");

    private int code;
    private String desc;

    private DeviceType(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {return code;}

    public void setCode(int code) {this.code = code;	}

    public String getDesc() {return desc;}

    public void setDesc(String desc) {this.desc = desc;}

    public static DeviceType getByCode(int code) {
        for (DeviceType deviceType : DeviceType.values()) {
            if (deviceType.getCode() == code) {
                return deviceType;
            }

        }
        return null;
    }
    public static List<EnumModal> toList(){
        List<EnumModal> list = new ArrayList<>();
        for (DeviceType bean : DeviceType.values()) {
            EnumModal enumModal = new EnumModal();
            enumModal.setIndex(bean.ordinal());
            enumModal.setCode(bean.getCode());
            enumModal.setName(bean.name());
            enumModal.setDesc(bean.getDesc());
            list.add(enumModal);
        }
        return list;
    }
}
